﻿using System;
using UnityEngine;

public class AnimationControl:MonoBehaviour
{
	private Animation anima;

	void Awake(){
		anima = GetComponent<Animation> ();

		foreach (AnimationState ani in anima) {
			ani.clip.wrapMode = AnimationName.GetAnimationWrap (ani.name);
		}
	}

	public void PlayAnimation(AnimationType type){
		string animationName = AnimationName.GetAnimationName (type,anima);
		if (animationName != "") {
			anima.Play (animationName);
		}
	}

    public void PlayAnimation(string name)
    {
        if (name != "")
            anima.Play(name);
    }

    void Update(){

		if (!anima.isPlaying) {
			PlayAnimation (AnimationType.daiji);
		}
	}

}

